// import proFetch from "../../../../../public/functions/project-fetch";
import {hrAjax as ajax} from 'src/hrpub/common/utils/utils';
import updateButtonStatus from "./updateButtonStatus";
import getMainTableData from "./getMainTableData";
import handleAllpks from "./handleAllpks";
import {toast} from 'nc-lightapp-front';
import getOneAgreementInfo from "./getOneAgreementInfo";

export default function deleteAgreementData() {

    const {agreementType,orgVal,deletePks,pageFlag} = this.state;
    return ajax({
        url: '/nccloud/hrcm/agreement/ReleaseDeleteAction.do',
        body: {
            pk_agreements: deletePks
        },
    }).then((res) => {
        if (res.success) {
            if(pageFlag === 'list'){
                getMainTableData.call(this);
            }else if(pageFlag === 'card'){
                let getnextPk = handleAllpks.getNextPk(deletePks[0]);
                this.setState({
                    editPk: getnextPk,
                },()=>{
                    handleAllpks.remove(deletePks[0]); // 更新卡片分页主键
                    getOneAgreementInfo.call(this);
                });
            }
            updateButtonStatus.call(this, orgVal,agreementType);
            toast({color:'success',content:res.data.msg})
        }
    });
}
